package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yanjing.domain.FireFightingCheck;
import com.ruoyi.yanjing.service.IFireFightingCheckService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 消防设施日常点检信息Controller
 * 
 * @author whz
 * @date 2024-12-04
 */
@RestController
@RequestMapping("/yanjing/firefightingcheck")
public class FireFightingCheckController extends BaseController
{
    @Autowired
    private IFireFightingCheckService fireFightingCheckService;

    /**
     * 查询消防设施日常点检信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:firefightingcheck:list')")
    @GetMapping("/list")
    public TableDataInfo list(FireFightingCheck fireFightingCheck)
    {
        startPage();
        List<FireFightingCheck> list = fireFightingCheckService.selectFireFightingCheckList(fireFightingCheck);
        return getDataTable(list);
    }

    /**
     * 导出消防设施日常点检信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:firefightingcheck:export')")
    @Log(title = "消防设施日常点检信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FireFightingCheck fireFightingCheck)
    {
        List<FireFightingCheck> list = fireFightingCheckService.selectFireFightingCheckList(fireFightingCheck);
        ExcelUtil<FireFightingCheck> util = new ExcelUtil<FireFightingCheck>(FireFightingCheck.class);
        util.exportExcel(response, list, "消防设施日常点检信息数据");
    }

    /**
     * 获取消防设施日常点检信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:firefightingcheck:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fireFightingCheckService.selectFireFightingCheckById(id));
    }

    /**
     * 新增消防设施日常点检信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:firefightingcheck:add')")
    @Log(title = "消防设施日常点检信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FireFightingCheck fireFightingCheck)
    {
        return toAjax(fireFightingCheckService.insertFireFightingCheck(fireFightingCheck));
    }

    /**
     * 修改消防设施日常点检信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:firefightingcheck:edit')")
    @Log(title = "消防设施日常点检信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FireFightingCheck fireFightingCheck)
    {
        return toAjax(fireFightingCheckService.updateFireFightingCheck(fireFightingCheck));
    }

    /**
     * 删除消防设施日常点检信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:firefightingcheck:remove')")
    @Log(title = "消防设施日常点检信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fireFightingCheckService.deleteFireFightingCheckByIds(ids));
    }
}
